package com.lottery.mapper;

import com.lottery.model.Activity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 活动Mapper接口
 */
@Mapper
public interface ActivityMapper {
    
    /**
     * 插入活动
     */
    int insert(Activity activity);
    
    /**
     * 根据活动ID查询
     */
    Activity selectByActivityId(@Param("activityId") Long activityId);
    
    /**
     * 乐观锁更新库存
     */
    int deductStock(@Param("activityId") Long activityId, 
                    @Param("deductCount") Integer deductCount,
                    @Param("stockSurplusCount") Integer stockSurplusCount);
    
    /**
     * 更新活动状态
     */
    int updateState(@Param("activityId") Long activityId, @Param("state") Integer state);
    
    /**
     * 不安全的库存更新（没有乐观锁）
     */
    int deductStockUnsafe(@Param("activityId") Long activityId, 
                         @Param("deductCount") Integer deductCount);
} 